<wxs module="dateFr" src="../../js/filter.wxs"></wxs>
<view>
        <import src="../detail/detail" />
        <template is="{{template}}" data="{{my_toast_tip: my_toast_tip}}" />
    <view class="nouse">
        <text>不使用优惠券</text>
        <radio-group class="radio-group" bindchange="cancelCoupon">
            <label class="radio" >
                <radio color="#ffea00" value="" checked="{{!voucherMemberId}}" />
            </label>
        </radio-group>
    </view>
    <view class="divide">
        <text>选择可用优惠券</text>
    </view>
    <view class="couponList">
        <radio-group class="radio-group" bindchange="radioChange">
            <view class="couponItem {{coupon.canUse?'active':''}}" wx:for="{{coupons}}" wx:for-index="idx" wx:for-item="coupon" wx:key="idx">
                <image mode="aspectFit" wx:if="{{coupon.type=='meet_reduce'&&coupon.canUse}}" class="manjian" src="{{imageUrl}}/manjian.png"
                />
                <image mode="aspectFit" wx:if="{{coupon.type=='exclusive'&&coupon.canUse}}" class="xianjin" src="{{imageUrl}}/xianjin.png"
                />
                <view class="left">
                    <view>
                        <text>¥</text>
                        <text>{{util.formatNum(coupon.presentAmount)}}</text>
                    </view>
                    <view class="limit" wx:if="{{coupon.billAmountCondition}}">满{{util.formatNum(coupon.billAmountCondition)}}元可用</view>
                    <view class="limit" wx:else>无限额</view>
                </view>
                <view class="center">
                    <view class="sub">{{coupon.name}}</view>
                    <view>
                        <view class="time-limt">
                            <view class="s">
                                <image mode="aspectFit" src='{{imageUrl}}/list-style.png'></image>
                                <text>使用期限:{{util.formatDate(coupon.validStartTime)}}-{{util.formatDate(coupon.validEndTime)}}</text>
                            </view>
                        </view>
                       <!--  <view class="time-limt" wx:if="{{coupon.shopNames}}"> -->
                         <view class="time-limt" >
                            <view class="s {{coupon.rouleStyle}}" wx:if='{{coupon.rouleStyle=="shortRoule"}}'>
                                <image mode="aspectFit" src='{{imageUrl}}/list-style.png'></image>
                                <text>{{dateFr.fitRouls(coupon.goodsRouls,36)}}</text>
                            </view>

                            <view class="s {{coupon.rouleStyle}}" wx:if='{{coupon.rouleStyle!="shortRoule"}}'>
                                <image mode="aspectFit" src='{{imageUrl}}/list-style.png'></image>
                                <text>{{coupon.goodsRouls}}</text>
                            </view>
                             <d bindtap='showDetail' data-code='{{coupon.voucherId}}' wx:if='{{coupon.goodsRouls.length>36}}' class='moreInfo'>更多 <image class='{{coupon.transform_style}}' src="../../image/shouhui.png"></image></d>
                        </view>
                        <!-- <view class="time-limt" wx:if="{{coupon.goodNames}}">
                            <view class="s">
                                <image mode="aspectFit" src='{{imageUrl}}/list-style.png'></image>
                                <text> 此优惠券只适用于指定商品:{{util.formatShop(coupon.goodNames)}}</text>

                            </view>
                        </view>
                        <view class="time-limt" wx:if="{{!coupon.goodNames && !coupon.shopNames}}">
                            <view class="s">
                                <image mode="aspectFit" src='{{imageUrl}}/list-style.png'></image>
                                <text>此优惠券为通用券</text>
                            </view>
                        </view> -->
                    </view>
                </view>
                <view class="right">
                    <label class="radio">
                        <radio hidden="{{!coupon.canUse}}" color='#ffea00' value="{{coupon.voucherMemberId}}" checked="{{coupon.checked}}" />
                    </label>

                </view>
            </view>
        </radio-group>

    </view>
    <!-- <radio-group class="couponList" bindchange="radioChange">
            <view class="couponItem" wx:for="{{items}}">
                <view class="left">
                    <text class="text1">4</text>
                    <text lass="text2">满40可以</text>
                </view>
                <view class="center">
                    <text>现金10月福利</text>

                </view>
                <radio value="{{item.name}}" />
            </view>
    </radio-group> -->
</view>
<wxs module="util">
    var formatNum=function(n){ 
        return Number(n) 
    } 
    var formatNumber =function(n){ 
        n = n.toString() return n[1] ? n : '0' + n 
    }
    var formatDate=function(millisecond){ 
        var date=getDate(millisecond), 
        year = date.getFullYear(), 
        month = date.getMonth()+ 1, 
        day = date.getDate(), 
        hour = date.getHours(), 
        minute = date.getMinutes(), 
        second = date.getSeconds(); 
        return [year,month, day].map(formatNumber).join('.');
    } 
    var formatShop=function(array){ 
            return array.join('、') 
    } 
    module.exports =
    { formatNum : formatNum, formatDate:formatDate, formatShop:formatShop }
</wxs>